<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script src="/layui/layui.js"></script>
    <link href="/layui/css/layui.css" rel="stylesheet">
</head>
<body>
<h1>欢迎使用xxx后台管理系统</h1>
<div class="layui-btn-container">
    <button type="button" id="select" class="layui-btn">查询</button>
    <button type="button" id="add" class="layui-btn layui-bg-blue">添加</button>
    <button type="button" id="update" class="layui-btn layui-bg-orange">修改</button>
    <button type="button" id="delete" class="layui-btn layui-bg-red">删除</button>
</div>
</body>

<script type="text/javascript">

    layui.use(function(){
        let form = layui.form;
        let layer = layui.layer;
        let $ =layui.jquery;

        $("#select").on("click",function (){
            $.get('/user/list',function (res){
                    layer.msg(JSON.stringify(res))
            })
        })

        $("#add").on("click",function (){
            let user = {
                username:'jack',
                password:'123456',
                age:20
            }
            $.post('/user/add',user,function (res){
                    layer.msg(res.message)
            })
        })

        $("#update").on("click",function (){
            let user = {
                id:60,
                username:'jack',
                password:'123456',
                age:20
            }
            $.post('/user/update',function (res){
                    layer.msg(res.message)
            })
        })

        $("#delete").on("click",function (){

            $.post('/user/delete',{id:60},function (res){
                    layer.msg(res.message)
            })
        })
    });

</script>

</html>